package com.gaozhen.demo;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        //1、买飞机票的价格计算
        Scanner p = new Scanner(System.in);
        System.out.println("请输入买飞机票的价格：");
        double price = p.nextDouble();

        System.out.println("请输入买飞机票的月份(1-12)：");
        int month = p.nextInt();

        System.out.println("请输入仓位类型：");
        String type = p.next();

        System.out.println(cal(price, month, type));
    }
    /*定义方法
    **/
    public static double cal(double price,int month,String type){
            if (month >= 5 && month <= 10) {
                //旺季
                switch (type) {
                    case "头等舱":
                        price *= 0.9;
                        break;
                    case "经济舱":
                        price *= 0.85;
                        break;
                    default:
                        price = -1;
                }
            } else if (month == 11 || month == 12 || (month >= 1 && month <= 4)) {
                //淡季
                switch (type) {
                    case "头等舱":
                        price *= 0.7;
                        break;
                    case "经济舱":
                        price *= 0.65;
                        break;
                    default:
                        price = -1;
                }
            } else {
                System.out.println("月份输入有误！");
                price = -1;
            }
            return price;

    }
}
